import 'package:flu_framework/res/colors.dart';
import 'package:flutter/material.dart';

class XdCourseLable extends StatelessWidget {

  static const int STATUS_NOT_BEGIN = 0;
  static const int STATUS_BEGIN = 1;
  static const int STATUS_OVER = 2;

  static const int PAGE_MY_COURSE = 0;
  static const int PAGE_COURSE_SECTION = 1;

  static const int STATUS_COURSE_NOT_OVER = 0; // 未结课
  static const int STATUS_COURSE_OVER = 1; // 已结课

  String? labelText;
  TextStyle? labelTextStyle;
  final EdgeInsets? lablePadding;
  ///圆角度数
  final int radiusData;
  final double bottomLeftRadius;
  final double topRightRadius;
  ///标签背景颜色
  Color? labelBgColor;
  final int? status;
  final int? page;

  XdCourseLable({
    Key? key,
    this.labelText,
    this.labelTextStyle,
    this.lablePadding =const EdgeInsets.only(left: 8,right: 8,top: 2,bottom:2),
    this.radiusData = 12,
    this.bottomLeftRadius = 8,
    this.topRightRadius = 12,
    this.labelBgColor = Colors.cyan,
    this.status = -1,
    this.page = -1,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return _buildLable();
  }

  Widget _buildLable(){
    if(this.page == PAGE_MY_COURSE) {
      switch(status) {
        case STATUS_COURSE_NOT_OVER:
          this.labelText = "未结课";
          this.labelTextStyle = TextStyle(color: ZXColors.text_status_lable_green,fontSize: 12);
          this.labelBgColor = ZXColors.bg_status_lable_green;
          break;
        case STATUS_COURSE_OVER:
          this.labelText = "已结课";
          this.labelTextStyle = TextStyle(color: ZXColors.text_status_lable_grey,fontSize: 12);
          this.labelBgColor = ZXColors.bg_status_lable_grey;
          break;
      }
    }else if(this.page == PAGE_COURSE_SECTION){
      switch(status) {
        case STATUS_NOT_BEGIN:
          this.labelText = "未开始";
          this.labelTextStyle = TextStyle(color: ZXColors.text_status_lable_blue,fontSize: 12);
          this.labelBgColor = ZXColors.bg_status_lable_blue;
          break;
        case STATUS_BEGIN:
          this.labelText = "进行中";
          this.labelTextStyle = TextStyle(color: ZXColors.text_status_lable_green,fontSize: 12);
          this.labelBgColor = ZXColors.bg_status_lable_green;
          break;
        case STATUS_OVER:
          this.labelText = "已结束";
          this.labelTextStyle = TextStyle(color: ZXColors.text_status_lable_grey,fontSize: 12);
          this.labelBgColor = ZXColors.bg_status_lable_grey;
          break;
      }
    }


    return Container(
      padding: this.lablePadding,
      decoration: BoxDecoration(
          color:labelBgColor!,
          borderRadius: BorderRadius.only(bottomLeft: Radius.circular(bottomLeftRadius),topRight: Radius.circular(topRightRadius))
      ),
      child: Text(this.labelText??"",style: this.labelTextStyle,),
    );
  }
}
